package ua.ck.example.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import ua.ck.example.domain.Category;

@Repository
public class CategoryDAOImpl implements CategoryDAO {
	@Autowired
	private SessionFactory sessionFactory;

	@Override
	public List<Category> listCategories() {
		return sessionFactory.getCurrentSession()
				.createQuery("from Category").list();
	}

	@Override
	public void addCategory(Category category) {
		sessionFactory.getCurrentSession().save(category);

	}

}
